﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;

namespace SimSpike
{
    public partial class JudgeScreen11 : Form
    {
        Socket sck;
        public bool isScoringTime = true;

        public JudgeScreen11()
        {
            InitializeComponent();
            sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sck.Connect("127.0.0.1", 888);
            UpdateWindow();
            
        }

        public void UpdateWindow()
        {
            if (!isScoringTime)
            {
                lblIsCompleted.Text = "Waiting on diver...";
                grpPoints.Enabled = false;
            }
            else if (isScoringTime)
            {
                lblIsCompleted.Text = "Dive completed!";
                grpPoints.Enabled = true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            sck.Close();
            sck.Dispose();
            Close();
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string points = trkPoint.Value.ToString();
            int s = sck.Send(Encoding.Default.GetBytes(points));

            if (s > 0)
            {
                MessageBox.Show("Points Sent");
            }
        }
        
       
    }
}
